/**
 * CS575 Software Design
 * Group 6
 * Group Members: Anthony Davidson, Kendra Scheesley, Lyndsey Whitman, Stephen Zakrewsky
 * Date: May 19, 2012
 * Main Author(s): Lyndsey Whitman
 * 
 * Modified: 6/1 Stephen Zakrewsky
 */

package edu.drexel.cs575.a3;

import java.io.OutputStream;
import java.io.PrintStream;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.List;

import edu.drexel.cs575.a3.location.LocaleEnum;
import edu.drexel.cs575.a3.location.Location;
import edu.drexel.cs575.a3.location.LocationProvider;

public class ItemizedBill implements Bill
{
	private PrintStream		out;
	private List<String>	buffer;
	
	ItemizedBill()
	{
	}

	ItemizedBill(OutputStream out)
	{
		this.out = new PrintStream(out);
		this.buffer = new ArrayList<String>();
	}
	
	public void setOutputStream(OutputStream out)
	{
		this.out = new PrintStream(out);
		this.buffer = new ArrayList<String>();

	}

	@Override
	public void printBill()
	{
		for (String line : buffer)
		{
			out.println(line);
		}
	}

	@Override
	public void setLocaleEnum(LocaleEnum le)
	{
		// TODO Auto-generated method stub
	}

	@Override
	public void displayItem(String name, double price, double weight,
			String units)
	{
		Location location = LocationProvider.getInstance().getLocation();
		LocaleEnum locale = location.getLocaleEnum();

		NumberFormat currencyFormat = NumberFormat.getCurrencyInstance(locale.getLocale());

		String displayMsg = "Total price of " + name + ", " + currencyFormat.format(price);

		buffer.add(displayMsg);
	}

	@Override
	public void display(String text)
	{
		out.println(text);

	}
	


}
